package busca.tesoros.uclm;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class PosLoginActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.poslogin);
        
        View ButtonMisiones = findViewById(R.id.button_misiones);
        ButtonMisiones.setOnClickListener(this); 
        
        View ButtonAbout = findViewById(R.id.button_about);
        ButtonAbout.setOnClickListener(this); 
        
        View ButtonHelp = findViewById(R.id.button_help);
        ButtonHelp.setOnClickListener(this); }
   

	public void onClick(View v) {
    	switch (v.getId()) {
    	case R.id.button_misiones:
    		Intent i = new Intent(this, SelMisionActivity.class);
    		startActivity(i);
    		break;  
    		
    	case R.id.button_about:
    		Intent ii = new Intent(this, AcercaDeActivity.class);
    		startActivity(ii);
    		break; 
    		
    		
    	case R.id.button_help:
    		Intent iii = new Intent(this, AyudaActivity.class);
    		startActivity(iii);
    		break;  
    }
		
	}
	
	//
	//   Control Menu
	//
	private static final int MNU_OPC1 = 1;
	private static final int MNU_OPC2 = 2;
	private static final int MNU_OPC3 = 3;
	
	private static final int SMNU_OPC1 = 31;
	private static final int SMNU_OPC2 = 32;
	Boolean star=false;
	private TextView lblMensaje;
	MediaPlayer mp;
				
	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	Intent qr;
    	
        switch (item.getItemId()) {
        
            case R.id.menuimagen:
            	qr = new Intent(this,MostrarQRActivity.class);
          		startActivity(qr);		             
          		 return true;
          		               
            case R.id.menusalir:
            	qr = new Intent(this, FinActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            	startActivity(qr);
            	finish();
            	 return true;
            	 
            case R.id.menusonido:
            	if(star)
            	{
            	mp.stop();
            	star=false;
            	}
            	else
            	{		            		
                    mp = MediaPlayer.create(this, R.raw.melodia_de_fondo);
	            	mp.setLooping(true);
            		mp.start();
            		star=true;
            	}
            	return true;
		default:
                return super.onOptionsItemSelected(item);
        }
    }

}
